package cn.gjculture.shopping.api.dao;

import cn.gjculture.shopping.api.entity.GoodsRecord;
import cn.gjculture.shopping.api.entity.Order;
import cn.gjculture.shopping.api.entity.RefundFlow;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface OrderDao {
    @Insert("insert into `order`(orderId,customerId,orderSubject,orderSum,orderTotalSum,orderType,useScore,insertTime,updateTime,addressId,`status`,mark)" +
            " values(#{orderId},#{customerId},#{orderSubject},#{orderSum},#{orderTotalSum},#{orderType},#{useScore},#{insertTime},#{updateTime},#{addressId},#{status},#{mark}) ")
    int insert(Order order);

    @Update("update `order` set `status`=#{status},updateTime=#{updateTime} where orderId=#{orderId}")
    int updateStatus(Order order);

    @Select("select * from `order` where orderId=#{orderId}")
    Order queryById(String orderId);

    @Select("select * from `order` where customerId=#{customerId}")
    List<Order> queryByCustomerId(String customerId);

    @Select("select * from goodsrecord where orderId=#{orderId}")
    List<GoodsRecord> queryGoodsRecordByOrderId(String orderId);

    @Select("select * from `order` order by insertTime desc")
    List<Order> query();

    @Select("select count(1) from `order` where customerId=#{customerId} and `status`>=8 and `status`<=30")
    Integer queryCountBuyByCustomerId(String customerId);

    @Select("select * from refundflow where orderId=#{orderId}")
    RefundFlow queryRefundFlow(String orderId);
    @Select("select * from `order` where orderType=#{orderType}")
    List<Order> queryByOrderType(Integer orderType);
}
